<?php
	$hostName = "localhost";
	$username = "root";
	$password = "";
	$databaseName = "NTSon01_Nhom04";
?>
<?php
	function showError()
	{
		die("Error " . mysql_errno( ). " : " . mysql_error( ));
	}
?>
<?php
				if(!isset($_SESSION["Username"]))
				{	
					header("Location:index.php");
				}

       			include_once('class_sanpham.php');
				include_once('components/DanhMucSanPham/class_DanhMucSanPham.php');
				$MaNguoiBan = $_SESSION["MaUser"];
				$cnn = mysql_connect( $hostName, $username, $password );
				if ( ! $cnn )
					showError();
             
                $dbselect = mysql_select_db( $databaseName);
                if(!$dbselect)
                	showError();            
			
				
				$sql = 'select * 
				from san_pham
				where MaNguoiBan='.$MaNguoiBan;
				
				$result = mysql_query($sql, $cnn);
				if (!$result)
				{
					showError(); 	
				}
				else
				{
					$numrow = mysql_num_rows($result);
					
					echo '<table border="1" width="90%">';
					
					
					echo "<tr>";
						
						//echo "<th></th>";
						echo "<th>Tên sản phẩm</th>";
						echo "<th>Số lượng</th>";				
						echo "<th>Tình trạng đăng</th>";		
						echo "<th>Tình trạng xóa</th>";
						echo "<th>giá tiền</th>";

					echo "</tr>";
					
					
					while ($row = mysql_fetch_row($result))
					{
						$MaSo = $row[0];
						$TenSanPham= $row[1];
						$SoLuong = $row[6];
						$TinhTrangDang = $row[13];
						$TinhTrangXoa = $row[14];
						$GiaSanPham = $row[4];

						echo "<tr>";
							//echo "<td><input type='checkbox' name='chkMaHSs[]' value='$MaSo'/></td>";
							echo "<td><input type='text' id='$MaSo TenSanPham' value='$TenSanPham' class=\"cell\" /></td>";
							echo "<td><input type='text' id='$MaSo SoLuong' value='$SoLuong' class=\"cell\"/></td>";
							echo "<td><input type='text' id='$MaSo TinhTrangDang' value='$TinhTrangDang' class=\"cell\"/></td>";
							echo "<td><input type='text' id='$MaSo TinhTrangXoa' value='$TinhTrangXoa' class=\"cell\"/></td>";
							echo "<td><input type='text' id='$MaSo GiaSanPham' value='$GiaSanPham' class=\"cell\"/></td>";
							
							
							echo "<td>";
							echo "<input type='button' name='btnCapNhat' value='Update' onClick='capnhat($MaSo)' />";
							echo "</td>";
							
						
						echo "</tr>";			
					}
					
					echo "</table>";
				}
?>